package com.haizhi.crm.search.manager.impl;

import com.haizhi.crm.common.constant.SearchStatus;
import com.haizhi.crm.common.exception.UnexpectedStatusException;
import com.haizhi.crm.common.rest.RestService;
import com.haizhi.crm.search.manager.GdbSearchManager;
import com.haizhi.crm.search.model.GdbSearchResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created by chengmo on 2018/5/16.
 */
@Service
public class GdbSearchManagerImpl implements GdbSearchManager {

    private static final String PATH_STANDARD_ATLAS = "/standardAtlas";

    @Value("${search.manager.url.graph-search-arango:}" )
    private String restUrl;
    @Autowired
    private RestService restService;

    @Override
    public GdbSearchResp standardAtlasExpand(Map<String, Object> requestApi) {
        try {
            return restService.doPost(restUrl + PATH_STANDARD_ATLAS, requestApi, GdbSearchResp.class);
        } catch (Exception e) {
            throw new UnexpectedStatusException(SearchStatus.CALL_REST_ERROR, e, requestApi);
        }
    }
}
